package com.bjsxt.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bjsxt.mapper.HostMapper;
import com.bjsxt.pojo.Host;
import com.bjsxt.pojo.HostCondition;
import com.bjsxt.pojo.PageResult;
import com.bjsxt.service.IHostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2021-10-14
 */
@Service
public class HostServiceImpl extends ServiceImpl<HostMapper, Host> implements IHostService {
    @Autowired
    private HostMapper hostMapper;
    //分页加载主持人信息
    @Override
    public PageResult<Host> selHostInfoService(Integer page, Integer rows, HostCondition hostCondition) {
        //创建分页对象存储分页条件
        IPage<Host> p = new Page<>(page,rows);
        //调用mapper完成查询
        IPage<Host> hostIPage = hostMapper.selHostInfoMapper(p, hostCondition);
        //将结果封装pageResult并返回
        PageResult<Host> pageResult = new PageResult<>();
        pageResult.setTotal(hostIPage.getTotal());
        pageResult.setRows(hostIPage.getRecords());
        return pageResult;
    }
}
